package com.huangfuyi.process.managers;

import com.huangfuyi.process.actuator.definition.EPConditionParser;
import com.huangfuyi.process.actuator.definition.EPScheduler;
import com.huangfuyi.process.actuator.definition.defaultimpl.EPDefaultScheduler;
import com.huangfuyi.process.entity.instance.EPInstanceEntity;
import com.huangfuyi.process.entity.model.EPModelEntity;
import com.huangfuyi.process.entity.node.EPNodeEntity;
import com.huangfuyi.process.entity.node.EPNodeNextConfigEntity;
import com.huangfuyi.process.entity.running.EPParamEntity;
import com.huangfuyi.process.entity.running.EPRunningEntity;
import com.huangfuyi.process.utils.EPObjectUtils;

public class EPManagers {

    private static EPServiceManager<? extends EPInstanceEntity, ? extends EPModelEntity, ? extends EPNodeEntity, ? extends EPNodeNextConfigEntity, ? extends EPRunningEntity, ? extends EPParamEntity> serviceManager;

    private static EPNodeAppManager nodeAppManager;

    private static EPBeforeRunningManager beforeRunningManager;

    private static EPConditionParser conditionParser;

    private static EPScheduler scheduler;

    public static EPServiceManager<? extends EPInstanceEntity, ? extends EPModelEntity, ? extends EPNodeEntity, ? extends EPNodeNextConfigEntity, ? extends EPRunningEntity, ? extends EPParamEntity> getServiceManager() {
        return serviceManager;
    }

    public static void setServiceManager(EPServiceManager<? extends EPInstanceEntity, ? extends EPModelEntity, ? extends EPNodeEntity, ? extends EPNodeNextConfigEntity, ? extends EPRunningEntity, ? extends EPParamEntity> serviceManager) {
        EPManagers.serviceManager = serviceManager;
    }

    public static EPNodeAppManager getNodeAppManager() {
        return nodeAppManager;
    }

    public static void setNodeAppManager(EPNodeAppManager nodeAppManager) {
        EPManagers.nodeAppManager = nodeAppManager;
    }

    public static EPBeforeRunningManager getBeforeRunningManager() {
        return beforeRunningManager;
    }

    public static void setBeforeRunningManager(EPBeforeRunningManager beforeRunningManager) {
        EPManagers.beforeRunningManager = beforeRunningManager;
    }

    public static EPConditionParser getConditionParser() {
        return conditionParser;
    }

    public static void setConditionParser(EPConditionParser conditionParser) {
        EPManagers.conditionParser = conditionParser;
    }

    public static EPScheduler getScheduler() {
        if(EPObjectUtils.isEmpty(scheduler)){
            scheduler = new EPDefaultScheduler();
        }
        return scheduler;
    }

    public static void setScheduler(EPScheduler scheduler) {
        EPManagers.scheduler = scheduler;
    }
}
